package fr.idak.spring.tiles.dao.impl;

import static org.hibernate.criterion.Restrictions.eq;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import fr.idak.spring.tiles.dao.UserDao;
import fr.idak.spring.tiles.hibernate.entity.User;
import fr.idak.sring.tiles.generic.dao.GenericDaoHibernateImpl;

@Repository
public class UserDaoImpl extends GenericDaoHibernateImpl<User, Integer> implements UserDao {

	public User findUserByLogin(String login) {
		Session session = sessionFactory.getCurrentSession();
		Criteria criteria = session.createCriteria(entityClass);
		criteria.add(eq("login", login));
		return (User) criteria.uniqueResult();
	}
	
}
